<?php
/**
 * Functions for dynamically displaying tabular data
 * This file is not loaded by default in the theme
 * It is maintained for users that are using this functionality
 *
 * @copyright 2008 - 2009
 * @version 0.1
 * @author Justin Tadlock
 * @link http://justintadlock.com
 * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 *
 * @package TabularData
 */

/**
 * Easily create dynamic tables w/PHP
 * Put strings into function for th/td
 * Current functionality only allows for <th> and <td> within <tr> elements
 *
 * @todo Needs to be updated to accomodate more uses
 * @todo Should use an array of arguments, then be parsed with wp_parse_args()
 *
 * @since 0.1
 * @param array $tabular_data_header
 * @param array $tabular_data
 * @return string
 */
function tabular_data( $tabular_data_header = false, $tabular_data = false ) {

	echo '<table>';
		if ( $tabular_data_header ) echo '<tr>';

			foreach ( $tabular_data_header as $header ) :
				echo '<th>' . $header . '</th>';
			endforeach;

		if ( $tabular_data_header ) echo '</tr>';

			$tr_class = 'odd';

			foreach ( $tabular_data as $data ) :

				echo '<tr class="' . $tr_class . '">';
					foreach ( $data as $value ) :
						echo '<td>' . $value . '</td>';
					endforeach;
				echo '</tr>';

				if ( $tr_class == 'odd' )
					$tr_class = 'even alt';
				else
					$tr_class = 'odd';

			endforeach;
	echo '</table>';
}

?>